//
//  ViewController.m
//  MasonryDemo
//
//  Created by Zeak on 2017/2/16.
//  Copyright © 2017年 Zeak. All rights reserved.
//


//view上的view1，view1上的view2设置颜色没反应


#import "ViewController.h"
#import "Masonry.h"
#define  RANDOM_COLOR  [UIColor colorWithRed:arc4random() % 256 /255.0 green:arc4random() % 256 /255.0 blue:arc4random() % 256 /255.0 alpha:1]
#define SCREEN_WIDTH   [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT   [UIScreen mainScreen].bounds.size.height

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //随机颜色
//    self.view.backgroundColor = [UIColor colorWithRed:arc4random() % 256 /255.0 green:arc4random() % 256 /255.0 blue:arc4random() % 256 /255.0 alpha:1];
    
    
    UIView *sv = [[UIView alloc]init];
    sv.backgroundColor = [UIColor blackColor];
    [self.view addSubview:sv];
    [sv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(300, 300));
//      make.size.equalTo(CGSizeMake(300, 300));
    }];
    
    UIScrollView *scrollView = [[UIScrollView alloc]init];
    scrollView.backgroundColor = [UIColor whiteColor];
//  scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT);
    [sv addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(sv).with.insets(UIEdgeInsetsMake(5, 5, 5, 5));
    }];
    UIView *container = [[UIView alloc]init];
    container.backgroundColor = [UIColor greenColor];
    [scrollView addSubview:container];
    [container mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(scrollView);
        make.edges.equalTo(scrollView).with.insets(UIEdgeInsetsMake(0, 0, 0, 0));
//        make.width.equalTo(scrollView);
//        make.edges.equalTo(scrollView).with.insets(UIEdgeInsetsMake(5, 5, 5, 5));
    }];
    
    /*
    int count  = 10;
    UIView *lastView = nil;
    for (int i = 0; i < 10 ; i ++) {
        
        UIView *subv = [[UIView alloc]init];
        [container addSubview:subv];
        subv.backgroundColor = RANDOM_COLOR;
        [subv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(container);
            make.height.mas_equalTo(@(20 * i));
            if (lastView)
            {
                make.top.mas_equalTo(lastView.mas_bottom);
            }else
            {
                make.top.mas_equalTo(container.mas_top);
            }
        }];
        lastView = subv;
    }
    
    [container mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(lastView.mas_bottom);
    }];
    
    */
}

//        make.bottom.equalTo(leftImgView.mas_bottom).with.offset(12);



@end
